package com.me.control;

import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.me.constant.Constant;

public class WindowSettingControl extends Window{

	private Group titleGroup;
	private Skin skin;
	
	public WindowSettingControl(String title, Skin skin, float w, float h) {
		super(title, skin);
		this.skin = skin;
		this.setWidth(w);
		this.setHeight(h);
		this.setTitle("");
		this.showTitle(title); 
		this.pad(2,2,2,2);
		this.setMovable(false);
		this.setX((Constant.STAGE_WIDTH - w)/2);
		this.setY(Constant.STAGE_HEIGHT - h);
	}
	
	public float showTitle(String title){
		titleGroup = new Group();
		NinePatch patch = new NinePatch(skin.getRegion("window-tittle"), 27, 25, 23, 22); 
		Image image = new Image(patch);
		image.setWidth(this.getWidth()-10);
		image.setAlign(Align.center);
		image.setX((this.getWidth() - image.getWidth())/2);
		image.setY(-3);
		image.setHeight(60);
			
		Label labeltitle = new Label(title, skin, "default");
		labeltitle.setX(image.getWidth()/2 - labeltitle.getWidth()/2);
		labeltitle.setY(image.getHeight()/2 - labeltitle.getHeight()/2);
			
		titleGroup.setWidth(this.getWidth());
		titleGroup.setHeight(image.getHeight());
			
		titleGroup.addActor(image);
		titleGroup.addActor(labeltitle);
		this.top();
		this.add(titleGroup);
		this.row();
		return image.getHeight();
	}
	
	public float getWidthTitle()
	{
		return titleGroup.getWidth();
	}
	public float getHeightTitle()
	{
		return titleGroup.getHeight();
	}
}
